home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
qlib205.zip
/
QLIB.ZIP
/
SRC
/
QLIB
/
RAND.ASM
< prev
next >
Wrap
Assembly Source File
|
1997-07-13
|
991b
|
79 lines
include qlib.inc
include stdlib.inc
; ADDED : v2.01
;striped right from BC v5.0 LIBs! (with some modification)
.data
s1 dw 0
s2 dw 1
.code
srand proc,a:word
mov ax,a
mov s1,0
mov s2,ax
xor eax,eax
ret
srand endp
rand proc
pushad
mov cx,s1
mov bx,s2
mov dx,015Ah
mov ax,4E35h
xchg ax,si
xchg ax,dx
test ax,ax
jz @f
mul bx
@@:
jcxz @f
xchg ax,cx
mul si
add ax,cx
@@:
xchg ax,si
mul bx
add dx,si
add ax,1
adc dx,0
mov s1,dx
mov s2,ax
popad
xor eax,eax
mov ax,s1
and ax,7FFFh
ret
rand endp
randomize proc uses edx ebx
mov eax,gs:[46ch] ;timer tick
inc eax
mov ebx,gs:[41ah] ;kbd head/tail
inc ebx
mul ebx
callp srand,ax
xor eax,eax
ret
randomize endp
random proc uses ebx edx,a:word
;returns random num from 0 to (a-1)
callp rand
mov bx,a
xor edx,edx
idiv bx
xor eax,eax
mov ax,dx
ret
random endp
end